package com.feeyo.location

import android.content.Context
import android.content.Intent
import android.net.Uri
import com.feeyo.groundservice.base_util.SuccessCallback
import com.feeyo.groundservice.base_util.getConfirmDlg

/**
 *作者：QLH on 2020-04-23
 *描述：
 */
internal object NoPermissionAlert {

    @JvmStatic
    fun showDialog(context: Context, explain: String) {
        getConfirmDlg("", explain, null,"去设置", true, false,
            false, confirmListener = object : SuccessCallback {
                override fun success() {
                    goSettingPage(context)
                }
            })?.show()
    }


    private fun goSettingPage(context: Context) {
        val intent = Intent()
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        intent.action = "android.settings.APPLICATION_DETAILS_SETTINGS"
        intent.data = Uri.fromParts("package", context.packageName, null)
        context.startActivity(intent)
    }
}